<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>用户管理3</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(function() {
		var flag = '${flag}';
		$("#btnExport1,#btnExport2").click(function() {
			top.$.jBox.confirm("确认要导出数据吗？", "系统提示", function(v, h, f) {
				if (v == "ok") {
					exportExcel();
				}
			}, {
				buttonsFocus : 1
			});
			top.$('.jbox-body .jbox-icon').css('top', '55px');
		});
		$("#btnImport").click(function() {
			$.jBox($("#importBox").html(), {
				title : "导入数据",
				buttons : {
					"关闭" : true
				},
				bottomText : "导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"
			});
		});
	});
	function page(n, s) {
		var flag = '${flag}';
		$("#flagId").val(flag);
		if (n)
			$("#pageNo").val(n);
		if (s)
			$("#pageSize").val(s);
		var activityName = $("#activityId").val().trim();
		$("#mactivityId").val(activityName);
		var mmsProvinId = $("#mmsProvinId").val().trim();
		$("#mProvinId").val(mmsProvinId);
		var mmsCityId = $("#mmsCityId").val().trim();
		$("#mCityId").val(mmsCityId);
		var mmsGroupId = $("#mmsGroupId").val().trim();
		$("#mGroupId").val(mmsGroupId);
		
		if(flag == 2){
			var orderTypeIdV = $("#orderTypeId").val().trim();
			$("#morderTypeId").val(orderTypeIdV);
			var orderStateIdV = $("#orderStateId").val().trim();
			$("#mOrderStateId").val(orderStateIdV);
			
			var beginDateV = $("#beginDateId2").val().trim();
			$("#mBeginDate").val(beginDateV);
			var endDateV = $("#endDateId2").val().trim();
			$("#mEndDate").val(endDateV);
		}else{
			var beginDateV = $("#beginDateId").val().trim();
			$("#mBeginDate").val(beginDateV);
			var endDateV = $("#endDateId").val().trim();
			$("#mEndDate").val(endDateV);
		}
		
		$("#searchForm").attr("action", "${ctx}/mms/statistics/orderList");
		$("#searchForm").submit();
		return false;
	}
	
	function exportExcel(id) {
		var flag = '${flag}';
		$("#flagId").val(flag);
		var activityName = $("#activityId").val().trim();
		$("#mactivityId").val(activityName);
		var mmsProvinId = $("#mmsProvinId").val().trim();
		$("#mProvinId").val(mmsProvinId);
		var mmsCityId = $("#mmsCityId").val().trim();
		$("#mCityId").val(mmsCityId);
		var mmsGroupId = $("#mmsGroupId").val().trim();
		$("#mGroupId").val(mmsGroupId);
		
		if(flag == 2){
			var orderTypeIdV = $("#orderTypeId").val().trim();
			$("#morderTypeId").val(orderTypeIdV);
			var orderStateIdV = $("#orderStateId").val().trim();
			$("#mOrderStateId").val(orderStateIdV);
			
			var beginDateV = $("#beginDateId2").val().trim();
			$("#mBeginDate").val(beginDateV);
			var endDateV = $("#endDateId2").val().trim();
			$("#mEndDate").val(endDateV);
		}else{
			var beginDateV = $("#beginDateId").val().trim();
			$("#mBeginDate").val(beginDateV);
			var endDateV = $("#endDateId").val().trim();
			$("#mEndDate").val(endDateV);
		}
		if(id == 1){
			return false;
		}
		$("#searchForm").attr("action", "${ctx}/mms/statistics/export");
// 		alert($("#searchForm").attr("action"));
		$("#searchForm").submit();
		return false;
	}
	function getMmsProvin() {
		var id = $("#mmsProvinId").val();
		$("#searchForm").attr(
				"action",
				"${ctx}/mms/statistics/orderList?provinId=" + id + "&t="
						+ new Date().getTime());
		$("#searchForm").submit();
	}
</script>
</head>
<body>
	<form id="searchForm" modelAttribute="mmsProvince"
		action="${ctx}/mms/statistics/orderList" method="post"
		class="breadcrumb form-search ">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
			<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
			<input id="mProvinId" name="provinId" type="hidden" value="${provinId}"/>
			<input id="mCityId" name="mCityName" type="hidden" value="${mCityName}"/>
			<input id="mactivityId" name="activityName" type="hidden" value="${activityName}"/>
			<input id="mGroupId" name="groupId" type="hidden" value="${groupId}"/>
			<input id="flagId" name="flag" type="hidden" value="${flag}"/>
			<input id="mBeginDate" name="beginDate" type="hidden" value="${beginDate}"/>
			<input id="mEndDate" name="endDate" type="hidden" value="${endDate}"/>
			
			<input id="morderTypeId" name="mOrderTypeVal" type="hidden" value="${mOrderTypeVal}"/>
			<input id="mOrderStateId" name="mOrderStateVal" type="hidden" value="${mOrderStateVal}"/>
		<ul class="ul-form">
			<li><label>活动名称：</label> 
			<input maxlength="50" type="text" class="input-medium" id="activityId" value="${activityName}"/></li>
			<li><label>省份：</label> 
				<select onchange="getMmsProvin()" id="mmsProvinId" class="input-medium" >
					<option value="">--请选择--</option>
					<c:forEach items="${map.mmsProList}" var="pro">
						<option value="${pro.id }" <c:if test="${provinId eq pro.id}">selected="selected"</c:if>>${pro.name}</option>
					</c:forEach>
				</select>
			</li>
			<li><label>城市：</label>
				<select class="input-medium" id="mmsCityId">
					<option value="">--请选择--</option>
					<c:forEach items="${map.mmsCityList}" var="city">
						<option value="${city.id }" <c:if test="${mCityName eq city.id}">selected="selected"</c:if>>${city.name}</option>
					</c:forEach>
				</select>
			 </li>
			<li><label>所属组：</label> 
				<select class="input-medium" id="mmsGroupId">
					<option value="">--请选择--</option>
					<c:forEach items="${map.mmsGList}" var="group">
						<option value="${group.id }" <c:if test="${groupId eq group.id}">selected="selected"</c:if> >${group.name}</option>
					</c:forEach>
				</select>
			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary"
				type="submit" value="查询" onclick="return page();" />
			<li class="clearfix"></li>
		</ul>
	</form>
	<ul class="nav nav-tabs">
		<li <c:if test="${flag eq 1}">class="active"</c:if>><a href="${ctx}/mms/statistics/orderList?flag=1">领取资料信息</a></li>
		<li <c:if test="${flag eq 2}">class="active"</c:if>><a href="${ctx}/mms/statistics/orderList?flag=2">订单信息</a></li>
	</ul>
	<c:if test="${flag eq 2}">
		<form class="breadcrumb form-search ">
			<label>
				总订单数：<c:if test="${empty totalNum }">0</c:if><c:if test="${not empty totalNum }">${totalNum }</c:if>
			</label>
			<label>
				订单总额：<c:if test="${empty totalPrice }">0.0</c:if><c:if test="${not empty totalPrice }">${totalPrice }</c:if>
			</label>
			<label>
				已支付订单：<c:if test="${empty yesPayNum }">0.0</c:if><c:if test="${not empty yesPayNum }">${yesPayNum }</c:if>
			</label>
			<label>
				未支付订单：<c:if test="${empty noPayNum }">0.0</c:if><c:if test="${not empty noPayNum }">${noPayNum }</c:if>
			</label>
		</form>
	</c:if>
	<form  action="" method="post"
		class="breadcrumb form-search ">
			<%-- <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
			<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
			<input id="mProvinId" name="provinId" type="hidden" value="${provinId}"/>
			<input id="mCityId" name="mCityName" type="hidden" value="${mCityName}"/>
			<input id="mactivityId" name="activityName" type="hidden" value="${activityName}"/>
			<input id="mGroupId" name="groupId" type="hidden" value="${groupId}"/>
			<input id="flagId" name="flag" type="hidden" value="${flag}"/>
			<input id="mBeginDate" name="beginDate" type="hidden" value="${beginDate}"/>
			<input id="mEndDate" name="endDate" type="hidden" value="${endDate}"/>
			<input id="morderTypeId" name="mOrderTypeVal" type="hidden" value="${mOrderTypeVal}"/>
			<input id="mOrderStateId" name="mOrderStateVal" type="hidden" value="${mOrderStateVal}"/> --%>
		<div style="margin-top:8px;<c:if test='${flag eq 2 }'>display: none</c:if>">
			<label>领取时间：&nbsp;</label><input id="beginDateId" name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
				value="<fmt:formatDate value="${beginDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			<label>&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input id="endDateId" name="endDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
				value="<fmt:formatDate value="${endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();" />&nbsp;&nbsp;
			<input id="btnExport1" <c:if test='${exportFalg eq 0 }'>style="display: none;"</c:if> class="btn btn-primary" type="submit" value="导出" onclick="return exportExcel('1')"/>&nbsp;&nbsp;
		</div>
		<c:if test="${flag eq 2}">
			<ul class="ul-form" >
				<li><label>订单类型：</label> 
					<select  class="input-medium" id="orderTypeId">
						<option value="">--请选择--</option>
						<option value="1" <c:if test="${mOrderTypeVal eq 1 }">selected="selected"</c:if>>APP下单</option>
						<option value="2" <c:if test="${mOrderTypeVal eq 2 }">selected="selected"</c:if>>二维码下单</option>
						<option value="3" <c:if test="${mOrderTypeVal eq 3 }">selected="selected"</c:if>>图书下单</option>
						<option value="4" <c:if test="${mOrderTypeVal eq 4 }">selected="selected"</c:if>>海报/易拉宝</option>
					</select>
				</li>
				<li><label>支付状态：</label> 
					<select  class="input-medium" id="orderStateId">
						<option value="">--请选择--</option>
						<option value="1" <c:if test="${mOrderStateVal eq 1 }">selected="selected"</c:if>>已支付</option>
						<option value="2" <c:if test="${mOrderStateVal eq 2 }">selected="selected"</c:if>>未支付</option>
					</select>
				</li>
			<li>
				<label>下单时间：&nbsp;</label><input id="beginDateId2" name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
					value="<fmt:formatDate value="${beginDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				<label>&nbsp;--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input id="endDateId2" name="endDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate"
					value="<fmt:formatDate value="${endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();" />&nbsp;&nbsp;
				<input id="btnExport2" <c:if test='${exportFalg eq 0 }'>style="display: none;"</c:if> class="btn btn-primary" type="submit" value="导出" onclick="return exportExcel('1')"/>&nbsp;&nbsp;
			</li>
			</ul>
		</c:if>
	</form>
<%-- 	<sys:message content="${message}" /> --%>
<%-- 	<c:if test="${empty page}"> --%>
<!-- 		<div id="messageBox" class="alert alert-success hide" style="display: block;"><button data-dismiss="alert" class="close">×</button>抱歉，数据为空！</div> -->
<%-- 	</c:if> --%>
	<c:if test="${type eq 1}">
		<div id="messageBox" class="alert alert-success hide" style="display: block;"><button data-dismiss="alert" class="close">×</button>抱歉，您没有权限查询数据，请联系系统管理员！</div>
	</c:if>
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<c:if test="${flag eq 1 }">
					<th>订单ID</th>
					<th>领取时间</th>
					<th>学员用户名</th>
					<th>是否新用户</th>
					<th>手机号</th>
					<th>二维码编号</th>
					<th>二维码类型</th>
					<th>组名称</th>
					<th>位置</th>
					<th>活动名称</th>
				</c:if>
				<c:if test="${flag eq 2 }">
					<th>订单ID</th>
					<th>订单类型</th>
					<th>下单时间</th>
					<th>支付状态</th>
					<th>订单金额</th>
					<th>组名称</th>
					<th>位置</th>
					<th>活动名称</th>
					<shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission>
				</c:if>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="scann">
				<tr>
					<c:if test="${flag eq 1 }">
						<td>
							${scann.id}
						</td>
						<td>
							<fmt:formatDate value="${scann.createTime}" type="both"/>
						</td>
						<td>
							${scann.userName}
						</td>
						<td>
							<c:if test="${scann.isNewType eq 1}">新用户</c:if>
							<c:if test="${scann.isNewType eq 0}">老 用户</c:if>
							<c:if test="${empty scann.isNewType}">---</c:if>
						</td>
						<td>
							${scann.tele}
						</td>
						<td>
							${scann.qrId}
						</td>
						<td>
							<c:if test="${scann.qrType eq 1}">宣传单页</c:if>
							<c:if test="${scann.qrType eq 0}">书本</c:if>
							<c:if test="${scann.qrType eq 2}">海报/易拉宝</c:if>
							<c:if test="${empty scann.qrType}">---</c:if>
						</td>
						<td>
							${scann.groupName}
						</td>
						<td>
							${scann.groupProvinceName} > ${scann.groupCityName} 
						</td>
						<td>
							${scann.activityName}
						</td>
					</c:if>
					<c:if test="${flag eq 2 }">
						<td>${scann.id }</td>
						<td>
							<c:if test="${scann.orderType eq 1}">APP下单</c:if>
							<c:if test="${scann.orderType eq 2}">二维码宣传页下单</c:if>
							<c:if test="${scann.orderType eq 3}">图书下单</c:if>
							<c:if test="${scann.orderType eq 4}">海报/易拉宝</c:if>
						</td>
						<td>
							<fmt:formatDate value="${scann.placeOrderTime}" type="both"/>
						</td>
						<td>
							<c:if test="${scann.payStatus eq 1}">已支付</c:if>
							<c:if test="${scann.payStatus eq 0}">未支付</c:if>
						</td>
						<td>${scann.price }</td>
						<td>
							${scann.groupName}
						</td>
						<td>
							${scann.groupProvinceName}->${scann.groupCityName}
						</td>
						<td>${scann.activityName}</td>
<%-- 						<shiro:hasPermission name="sys:user:edit"> --%>
						<td>
		    				<a href="${ctx}/mms/statistics/getDetailById?id=${scann.id}">查看订单详情</a>
						</td>
<%-- 						</shiro:hasPermission> --%>
				</c:if>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>